/**
 * 匠言知识付费v2.0.0
 * Author: 山西匠言网络科技有限公司
 * 这不是一个免费软件，它受限于许可条款，你可以访问https://www.zsfzxkc.cn/获取更多详细信息。
 * This is not a free software, it under the license terms, you can visit https://www.zsffzxkc.cn/ get more details.
 */
<template>
	<view class="container">
			<jy-quick-btns></jy-quick-btns>
			<!-- 背景部分 -->
			<view class="fenxiao">
				<view class="fenxiao-top" :model="userinfo">
					<view class="fenxiao-top-left">
						<image :src="userinfo.avatar" mode="aspectFit"></image>
						<view class="nickname">
							<text>{{userinfo.nickname}}</text>
							<text class="tjr">推荐人:{{fxinfo.pnickname}}</text>
						</view>
					</view>
					<view class="fenxiao-top-conter">
						<text>可提现佣金</text>
						<text>{{fxinfo.yongjin}}</text>
					</view>
					<view class="fenxiao-top-right" @click="navigate('brokerage')">
						<text>提现</text>
					</view>
				</view>
			</view>
			
			
			<!-- 列表部分 -->
			<view class="fenxiao-list">
				<view class="fenxiao-list-item" @click="navigate('promotion-code')">
					<view class="item-left">
						<image src="../static/vipcode1.png" mode="aspectFit"></image>
						<text>我的推广码</text>
					</view>
					<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
				</view>
				<view class="fenxiao-list-item" @click="navigate('wo-team')">
					<view class="item-left">
						<image src="../static/myteam.png" mode=""></image>
						<text>我的团队</text>
					</view>
					<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
				</view>
				<view class="fenxiao-list-item" @click="navigate('brokerage')">
					<view class="item-left">
						<image src="../static/credit.png" mode=""></image>
						<text>我的佣金</text>
					</view>
					<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
				</view>
				<view class="fenxiao-list-item" @click="navigate('submit-data')" v-if="base_set.smallapp.is_sh == 0">
					<view class="item-left">
						<image src="../static/txinfo.png" mode=""></image>
						<text>提现资料</text>
					</view>
					<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
				</view>
			</view>
	</view>
</template>

<script>
	import {checkUserinfo} from '@/request/checkUserinfo'
	export default {
		data() {
			return {
				userinfo: {},
				fxinfo:{},
				base_set:[]
			};
		},
		onLoad() {
			let base_set = uni.getStorageSync('base_set')
			if (base_set) {
				this.base_set = base_set
			}
			let userinfo=uni.getStorageSync('userinfo')
			this.userinfo = userinfo.userdata
			this.getfxinfo()
		},
		onShow() {
			checkUserinfo()
			let userinfo=uni.getStorageSync('userinfo')
			this.userinfo = userinfo.userdata
			if(this.userinfo.is_fxs==0){
				uni.showToast({
					title:'您还不是分销商，请先升级为分销商',
					icon:'none'
				})
				setTimeout(()=>{
					uni.navigateBack()
				},1200)
			}
		},
		onShareAppMessage(res) {
			let path = getCurrentPages()
			let path_share = path[0].$page.fullPath
			let path_title = path[0].data.title
			let userinfo = uni.getStorageSync('userinfo')
			let base_set = uni.getStorageSync('base_set')
			if(userinfo.uid=='' || !userinfo.uid){
				uni.navigateTo({
					url:'../login/login'
				})
				return {
					title: '请先登录后再分享给好友',
					path: ''
				}
			}else{
				if (res.from === 'button') {
					
				}
				return {
					title: base_set.title,
					path: `${path_share}?pid=${userinfo.uid}`
				}
			}
		},
		methods: {
			getfxinfo(){
				const BASE_URL = uni.BASE_URL
				uni.request({
					url: BASE_URL+'index/fenxiao/fxinfo',
					method:'POST',
					data:{
						uid:this.userinfo.id
					},
					success:(res) =>{
						console.log(res.data);
						this.fxinfo=res.data.data
					},
					fail:(res)=> {
						console.log(res.data);
					}
				});
			},
			navigate(e) {
				uni.navigateTo({
					url: `../${e}/${e}`
				});
			},
			
		}
	}
</script>

<style lang="less" scoped>

.fenxiao {
	background-color: #4b89ff;
	&-top {
		padding: 80upx 30upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		&-left {
			display: flex;
			align-items: center;
			image {
				width: 90upx;
				height: 90upx;
				border-radius: 50%;
			}
			.nickname{
				display: flex;
				flex-direction: column;
				text {
					font-size: 34upx;
					color: #fff;
					margin-left: 20upx;
				}
				.tjr{
					font-size: 28upx;
				}
			}
			
		}
		&-conter {
			display: flex;
			flex-direction: column;
			text:nth-child(1) {
				font-size: 28upx;
				color: #fff;
			}
			text:last-child {
				font-size: 34upx;
				color: #fff;
			}
		}
		&-right {
			text {
				padding: 10upx 20upx;
				font-size: 30upx;
				color: #fff;
				border: 2upx solid #fff;
				border-radius: 10upx;
			}
		}
	}
	&-bottom {
		display: flex;
		justify-content: space-between;
		.list-item {
			border-right: 2upx solid rgba(256,256,256,.4);
			color: #fff;
			margin-bottom: 20upx;
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			text {
				font-size: 30upx;
			}
			text:nth-child(2) {
				margin-top: 10upx;
			}
		}
		.list-item:last-child {
			border-right: 0;
		}
	}
}




.fenxiao-list {
	&-item {
		height: 100upx;
		padding: 0 30upx;
		border-bottom: 2upx solid #ddd;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.item-left {
			display: flex;
			align-items: center;
			image {
				width: 45upx;
				height: 45upx;
			}
			text {
				font-size: 30upx;
				color: #333;
				margin-left: 30upx;
			}
		}
		.item-right {
			width: 20upx;
			height: 30upx;
		}
	}
}

</style>
